<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="<?=base_url() ?>css/weui.min.css">
    <link rel="stylesheet" href="<?=base_url() ?>css/jquery-weui.min.css">
    <link rel="stylesheet" href="<?=base_url() ?>css/invite.css">
    <script src="<?=base_url() ?>js/jquery-2.1.4.js"></script>
    <script src="<?=base_url() ?>js/jquery-weui.min.js"></script>
</head>
<body>

<style>
    .box{
        position: fixed;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.2);
        z-index: 9999;
        display: none;
    }
    .pics{
        position: fixed;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.7);
        z-index: 9999;
        display: none;
    }
    .box1{
        width: 500px;
        height: 500px;
        position: fixed;left: 50%; top: 25%;
        margin-left: -250px;
        border: 0px ;
    }
    .box2{
        width: 90%;
        position: fixed;
        left: 5%;
        top: 100px;
        border: 0px;
    }
</style>
<div class="box">
    <div class="box1">
        <div style="width: 20%;height: 50px;position: absolute;right: 0px" onclick="jQuery('.box').hide()" class="close"></div>
        <img class="imgInvite" src="<?=base_url() ?>images/invite_10.jpg">
    </div>
</div>
<div class="pics">
    <div class="box2">
        <img class="imgInvite" src="<?=base_url() ?>images/tishi.png">
    </div>
</div>

<div class="content">
    <input type="hidden" id="mid" name="mid" value="<?php echo $mid?>">
    <img class="imgInvite" src="<?=base_url() ?>images/invite_01.jpg">
    <img class="imgInvite" src="<?=base_url() ?>images/invite_03.jpg">
    <img class="imgInvite" src="<?=base_url() ?>images/invite_04.jpg">
    <img class="imgInvite" src="<?=base_url() ?>images/invite_05.jpg">
    <img class="imgInvite" src="<?=base_url() ?>images/invite_06.jpg">
    <img class="imgInvite" src="<?=base_url() ?>images/invite_07.jpg">

    <h2 class="inviteTitle" style="font-size: 1.6rem;">立即注册销售经理</h2>

    <div class="inviteRegister">
        <div class="weui-cells weui-cells_form" style="border-radius: 8px;border:0.5px solid #ddd;">
            <div class="weui-cell weui-cell_vcode">
                <div class="weui-cell__bd">
                    <input id="invitePhone" class="weui-input" type="tel" placeholder="请输入手机号" style="height: 3.5rem;font-size: 1.6rem;">
                </div>
            </div>
        </div>
        <div class="weui-cells weui-cells_form" style="border-radius: 8px;border:0.5px solid #ddd;">
            <div class="weui-cell weui-cell_vcode">
                <div class="weui-cell__bd">
                    <input id="code" class="weui-input" type="tel" style="height: 3.5rem;font-size: 1.6rem;" placeholder="请输入验证码">
                </div>
                <div id="weui-cell__ft" class="weui-cell__ft">
                    <button id="inviteSend" class="weui-vcode-btn" style="color: #ff1000;width: 210px;font-size: 1.2rem;">获取验证码</button>
                </div>
            </div>
        </div>

        <div class="weui-cells weui-cells_form" style="border-radius: 8px;border:0.5px solid #ddd;">
            <div class="weui-cell weui-cell_vcode">
                <div class="weui-cell__bd">
                    <input id="password" class="weui-input" style="height: 3.5rem;font-size: 1.6rem;" type="password" placeholder="请设置密码" style="height: 45px;">
                </div>
            </div>
        </div>

        <div class="weui-cells weui-cells_form" style="border-radius: 8px;border:0.5px solid #ddd;">
            <div class="weui-cell weui-cell_vcode">
                <div class="weui-cell__bd">
                    <input id="rqpassword" class="weui-input" style="height: 3.5rem;font-size: 1.6rem;" type="password" placeholder="请确认密码" style="height: 45px;">
                </div>
            </div>
        </div>

        <div id="inviteRegister" class="weui-btn-area" style="margin: 1.17647059em 0px .3em;">
            <a class="weui-btn weui-btn_primary" href="javascript:" style="background-color:#ff1000;font-size: 1.4rem" id="showTooltips">注册</a>
        </div>

        <label for="weuiAgree" class="weui-agree" style="text-align: center;padding: 1.5em 15px;">
            <input id="weuiAgree" type="checkbox" style="zoom: 2.5" class="weui-agree__checkbox">
                 <span class="weui-agree__text" style="font-size: 1.1rem">
                        阅读并同意<a href="javascript:void(0);" style="color: #ff1000;">《销售经理协议》</a>
                 </span>
        </label>

    </div>

    <table width="100%" style="text-align: center">
        <tr>
            <td style="width: 50%"><img height="470rem" src="<?=base_url() ?>images/invite_09.jpg"></td>
            <td style="width: 50%">
                <ul style="width: 100%;">
                    <li style="list-style-type:none;"><a href="javascript:;" id="loadapp" class="weui-btn weui-btn_mini weui-btn_default inviteDownButton" style="font-size: 1.6rem">点击下载APP</a></li>
                    <li style="list-style-type:none;"><br></li>
                    <li style="list-style-type:none;"><br></li>
                    <li style="list-style-type:none;"><br></li>
                    <li style="list-style-type:none;"><span style="font-size: 1.3rem">无需门店，无需资金</span></li>
                    <li style="list-style-type:none;"><span style="font-size: 1.3rem">分享3万亿办公采购大市场</span></li>
                </ul>
            </td>
        </tr>
    </table>

</div>

<script>
    var sendUrl="<?=base_url()?>users/send_new";
    var registerUrl="<?=base_url() ?>users/register";
    var session_id="";

    $('.inviteDown').on('click', function(){
        window.location.href="http://www.tunqu.net/wx/index/home.html";//下载app地址
    });

    // 微信浏览器打开提示
    var ua = window.navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == 'micromessenger') {
        jQuery('.pics').show();
    }

    $("#loadapp").on('click', function(){
        if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { //判断iPhone|iPad|iPod|iOS
            window.location.href ="https://itunes.apple.com/cn/app/id1279188268?mt=8";
        } else if (/(Android)/i.test(navigator.userAgent)) {  //判断Android
            window.location.href ="http://zhushou.360.cn/detail/index/soft_id/3892344?recrefer=SE_D_%E8%B5%9A%E9%92%B1%E9%9B%84%E5%99%A8#nogo";
        } else { //pc
            window.location.href ="http://www.tunqu.net/wx/index/home.html";
        };
    });

    $('#weui-cell__ft').on('click', function(){
        var phoneText=$('#invitePhone').val();
        if(phoneText==""){
        	$.toast("请输入手机号", "text");
        	return;
        }
        if(checkMobile(phoneText)){
            $.ajax({
                type: 'POST',
                url: sendUrl,
                data:{tel:phoneText},
                dataType: 'json',
                success: function(data){
                    if(data.status=='success'){
                    	session_id=data.data;
                    	time();
                    }
                    $.toast(data.msg, "text");
                },
                error: function(xhr, type){

                }
            });
        }else{
            $.toast("手机号格式错误", "text");
        }
    });

    $('#inviteRegister').on('click', function(){
    	if(document.getElementById("weuiAgree").checked == true){
    		 var phoneText=$('#invitePhone').val();
    		 var code=$('#code').val();
    		 var password=$('#password').val();
    		 var repwd=$('#rqpassword').val();
    		 if(phoneText==""){
    	        	$.toast("请输入手机号", "text");
    	        	return;
    	     } 

    		 if(code==""){
 	        	$.toast("请输入验证码", "text");
 	        	return;
 	         }

    		 if(password==""){
 	        	$.toast("请设置密码", "text");
 	        	return;
 	         }

    		 if(repwd==""){
  	        	$.toast("请确认密码", "text");
  	        	return;
  	         }

  	         if(password!=repwd){
  	        	$.toast("密码不一致", "text");
  	        	return;
  	  	  	 }
            var mid = $("#mid").val();

  	       $.ajax({
               type: 'POST',
               url: registerUrl,
               data:{tel:phoneText,session_id:session_id,code:code,password:password,mid:mid},
               dataType: 'json',
               success: function(data){
                   if(data.status=='success'){
                       setTimeout(function() {
//                		   window.location.href="http://www.tunqu.net/wx/index/home.html";//注册成功跳转
                           // 显示图片
                           jQuery('.box').show();

                       }, 500); 
                   }
                       $.toast(data.msg, "text");
               },
               error: function(xhr, type){

               }
           });
    		 
        }else{
        	 $.toast("请先同意使用协议", "text");
        }
    });

    /**
     * 验证手机
     * @param str
     * @returns {Boolean}
     */
    function checkMobile(str) {
        var re = /^1\d{10}$/
        if (re.test(str)) {
            return true;
        } else {
            return false;
        }
    }

    var wait=60;
    function time() {
        if (wait == 0) {
            $("#inviteSend").css("color", "#ff1000");
            $("#inviteSend").attr("disabled", false);
            $('#inviteSend').text("获取验证码");
            wait = 60;
        } else {
            $("#inviteSend").css("color", "#999");
            $("#inviteSend").attr("disabled", true);
            $('#inviteSend').text( wait + "s");
            wait--;
            setTimeout(function() {
                   time()
            }, 1000);
        }
    }
</script>
</body>
</html>